package com.agileboot.domain.bot.conversationRecord.query;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.bot.conversationRecord.db.ConversationRecordEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

/**
 * 会话记录查询条件
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ConversationRecordQuery extends AbstractPageQuery<ConversationRecordEntity> {

    private String spoken;
    private String receivedName;
    private String groupName;
    private String roomType;
    private String answer;

    @Override
    public QueryWrapper<ConversationRecordEntity> addQueryCondition() {
        QueryWrapper<ConversationRecordEntity> queryWrapper = new QueryWrapper<ConversationRecordEntity>()
                .like(StrUtil.isNotEmpty(spoken), "spoken", spoken)
                .like(StrUtil.isNotEmpty(receivedName), "received_name", receivedName)
                .like(StrUtil.isNotEmpty(groupName), "group_name", groupName)
                .eq(StrUtil.isNotEmpty(roomType), "room_type", roomType)
                .like(StrUtil.isNotEmpty(answer), "answer", answer);

        this.setTimeRangeColumn("create_time");
        return queryWrapper;
    }
}
